package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.ShareFarmListVO;
import com.digitalchina.lxnsy.interfaces.ICallBackActivity;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/8/10 11:10
 * 修改备注：
 * ================================================
 */

public class ShareFarmSoldOutHolder extends BaseViewHolder<ShareFarmListVO> {

    private SimpleDraweeView ivPicture;
    private TextView tvType;
    private TextView tvPrice;
    private TextView tvTitle;
    private TextView tvSell;
    private TextView tvEdit;
    private  ICallBackActivity iCallBack;


    public ShareFarmSoldOutHolder(ViewGroup parent, ICallBackActivity iCallBack) {
        super(parent, R.layout.item_share_sold_out);
        ivPicture = $(R.id.sdv_images);
        tvTitle = $(R.id.tv_title);
        tvType = $(R.id.tv_type);
        tvPrice = $(R.id.tv_price);
        tvSell = $(R.id.tv_sell);
        tvEdit = $(R.id.tv_edit);

        this.iCallBack = iCallBack;
    }

    @Override
    public void setData(ShareFarmListVO data) {
        super.setData(data);

        // 上架
        tvSell.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                iCallBack.manage(getAdapterPosition());
            }
        });
        // 编辑
        tvEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                iCallBack.edit(getAdapterPosition());
            }
        });

       /* String url = "";
        if (data.getProductImageList() != null && data.getProductImageList().size() > 0)
            url = data.getProductImageList().get(0).getImage();
        FrescoUtil.showImageSmall(url, ivPicture);


        if(data.getAgricultureProductPriceList()!=null){
            switch (data.getAgricultureProductPriceList().size()){
                case 1:
                    if(data.getAgricultureProductPriceList().get(0).getAttrName().equals("出售")){
                        tvType.setVisibility(View.GONE);
                        tvPrice.setText(data.getPrice() + "元");
                        tvTitle.setText(data.getName() + "");
                    }else{
                        tvType.setVisibility(View.VISIBLE);
                        tvType.setText("保证金￥" + data.getEnsureMoney() + "元");
                        tvPrice.setText(data.getPrice() + "元/" +  data.getUnit().getName());
                        tvTitle.setText(data.getName() + "");
                    }
                    break;
                case 2:
                    tvType.setVisibility(View.VISIBLE);
                    tvType.setText("保证金￥" + data.getEnsureMoney() + "元");
                    tvPrice.setText(data.getPrice() + "元/" + data.getUnit().getName());
                    tvTitle.setText(data.getName() + "");
                    break;
            }
        }*/

    }

}
